<!-- Add fancyBox main JS and CSS files -->
<?php echo $this->headScript();?>
<?php echo $this->headLink();?>
<form id="frmresume" action="/resume" method="post">
<div class="block-search">
	<label>Search</label>
	<select name="choice" style="width:110px"> 
        <option value="">-- Choice -- </option>
		<option value="full_name" <?php echo ($this->choice == 'full_name')? 'selected': ''?>>Name</option>
		<option value="resume_code" <?php echo ($this->choice == 'resume_code')? 'selected': ''?>>Resume Code</option>
		<option value="job_title" <?php echo ($this->choice == 'job_title')? 'selected': ''?>>Job Title</option>
	</select>
	<input type="text" name="search"  value="<?php echo $this->search;?>"/>
	<input  class="button01" id="button1" type="submit" value="Search" />
	<a href="#inline" class="fancybox" style="text-decoration:none;">
		<input class="button01" type="button" value="Advanced Search" />
	</a>
	<br />
	<br />
	<a href="/resume/personal-info" style="text-decoration:none;">
		<input class="button01" type="button" value="Add Resume" />
	</a>
    
    <input class="button01 delete" type="button" value="Delete" />
    <a href="/resume/export-email" style="text-decoration:none;">
        <input class="button01" id="export_email" type="button" value="Export Email" style="display: none"/>
    </a>
</div>  
<p class="today-entry" id="report">&nbsp;</p>
<div style="clear:both"></div>
<div id="box">
    <?php echo $this->partial ( '/resume/list-resume.phtml', array('paginator' => $this->paginator, 'choice' => $this->choice, 'search' => $this->search) )?>
</div>
</form>
<?php echo $this->partial ( '/resume/avandced-search.phtml' )?>
<?php echo $this->partial ( '/resume/comment.phtml' )?>
<?php echo $this->partial ( '/resume/history.phtml' )?>
<div id="allcomment" style="width:500px;height:200px; overflow-y:scroll; display: none;">&nbsp;</div>
<div id="allhistory" style="width:500px;height:200px; overflow-y:scroll; display: none;">&nbsp;</div>
<div id="detail_resume" style="width:700px;height: 450px; overflow-y:scroll; display: none;">&nbsp;</div>
<script type="text/javascript">
$(document).ready(function() {
    //Begin Avansearch
    $(".fancybox").fancybox();
    $("#avansearch").click(function(){
    	checkLogin();
        var name = $('#full_name').val();
        var email = $('#email').val();
        var phone = $('#phone').val();
        var gender = $('input[name=gender]:radio:checked').val();
        var marital_status = $('input[name=marital_status]:radio:checked').val();
        var job_title = $('#job_title').val();
        var company_name = $('#company_name').val();
        var symbol = $('#symbol').val();
        var salary = $('#salary').val();
        var experother = $('#experother').val();
        var keyword = $('#keyword').val();
        var school_name = $('#school_name').val();
        var program_name = $('#program_name').val();
        var program_name = $('#program_name').val();
        
        var functions = '';
        var checkboxes = $('input[name="function[]"]:checkbox:checked');
        checkboxes.each(function() {
        	if(functions) functions = functions + ',' + $(this).val();
        	else functions = $(this).val();
        });

        var provinces = '';
        var checkboxes = $('input[name="province[]"]:checkbox:checked');
        checkboxes.each(function() {
        	if(provinces) provinces = provinces + ',' + $(this).val();
        	else provinces = $(this).val();
        });

        var param = 'full_name: ' + name +
            ',email: ' + email +
            ',phone: ' + phone +
            ',gender: ' + gender +
            ',marital_status: ' + marital_status +
            ',job_title: ' + job_title +
            ',company_name: ' + company_name +
            ',symbol: ' + symbol +
            ',functions: ' + functions +
            ',salary: ' + salary +
            ',experother: ' + experother +
            ',keyword: ' + keyword +
            ',provinces: ' + provinces +
            ',school_name: ' + school_name +
            ',program_name: ' + program_name
            
        $.ajax({
      	  	url: '/resume/avandce-search',
        	type: "POST",
			data: { 
                full_name: name, 
                email: email, 
                phone: phone, 
                gender: gender, 
                marital_status: marital_status,
                job_title: job_title,
                company_name: company_name,
                symbol: symbol,
                functions: functions,
                salary: salary,
                experother: experother,
                keyword: keyword,
                provinces: provinces,
                school_name: school_name,
                program_name: program_name
            },
      	  	success: function(result) {
      	    	$('#box').html(result);
        	  	$.fancybox.close();
        	  	$('#export_email').attr('var', param);
                $('#export_email').show();
      	  	}
      	});
    });
    //End Avansearch
    
    $.ajax({
  	  	url: '/resume/resume-report',
  	  	success: function(result) {
  	    	$('#report').html(result);
  	  	}
  	});

    $('.delete').click(function(){
        if($('input[name="resume_chk[]"]').is(':checked')) {
            var answer = confirm('Are you sure you want to delete');
            if (answer) {
            	var listResume = '';
                var checkboxes = $('input[name="resume_chk[]"]:checkbox:checked');
                checkboxes.each(function() {
                	if(listResume) listResume = listResume + ',' + $(this).val();
                	else listResume = $(this).val();
                });
            	$.ajax({
              	  	url: '/resume/delete-resume',
                	type: "POST",
        			data: { 
                       listid: listResume
                    },
              	  	success: function(result) {
                  	  	$('#box').html(result);
              	  	}
              	});
            }
        } else {
            alert('Please select resume to delete');
            return false;
        }
  	});  
});
</script>
<script>
$(document).ready(function(){
    $("#function").click(function(){
    	checkLogin();
        if(($(".multiselect").css('display')) == 'none') $(".multiselect").show('slow');
    });

    $("#province").click(function(){
    	checkLogin();
        if(($(".multiselect1").css('display')) == 'none') $(".multiselect1").show('slow');
    });
});

$("body").click(function(e){
	var $parentClass = $(e.target).parents('.multiselect');
    if(e.target.className !== "function" && $parentClass.length < 1) {
    	$(".multiselect").hide('slow');
    } 

    var $parentClass = $(e.target).parents('.multiselect1');
    if(e.target.className !== "province" && $parentClass.length < 1) {
    	$(".multiselect1").hide('slow');
    }       
});
</script>
